package daily;

import java.util.Scanner;

public class MeiTuan02 {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        System.out.println(getMinCircleString(s));
    }

    private static int getMinCircleString(String s){
        int n = s.length();
        int[][] dp = new int[n+1][n+1];
        StringBuilder sb = new StringBuilder();
        for(int i = n-1; i >= 0; i--){
            sb.append(s.charAt(i));
        }
        String s1 = sb.toString();
        for(int i = 1; i <= s.length(); i++){
            for(int j = 1; j <= s.length(); j++){
                if(s.charAt(i-1) == s1.charAt(j-1)){
                    dp[i][j] = dp[i-1][j-1] + 1;
                }else if(dp[i-1][j] >= dp[i][j-1]){
                    dp[i][j] = dp[i-1][j];
                }else{
                    dp[i][j] = dp[i][j-1];
                }
            }
        }
        return n - dp[n][n];
    }
}
